package com.itheima.outputstream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/*
如果要自己处理异常代码应该如何写
 */
public class Demo05 {

    public static void main(String[] args){

        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream("day12\\aaa\\a.txt", true);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            fos.write("嘿嘿嘿,我最帅".getBytes());
            fos.write("\r\n".getBytes());
            fos.write("呵呵呵,你放屁".getBytes());
            //
            fos=null;
            int i=1/0;
        } catch (Exception e) {
            e.printStackTrace();
        }finally {//释放资源
            if (fos!=null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        //finally
        // fos.write(10);//10 换行  13 回车
        //fos.write("\r".getBytes());

        while(true){}
    }
}
